<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2019 幕小铺科技（大连）有限公司 [ http://www.XXX.com ]
// +----------------------------------------------------------------------
// | 2020/03/14 jason wang
// +----------------------------------------------------------------------
namespace app\common\logic;

use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;

class NumberAuthenticationlogic{
	
	
    private $keyId           = 'LTAI4FmtZLM3wactLdEi52tP';//阿里云短信accessKeyId 
    private $keyScret        = '4TcKFrb5s8ZwfOxHah3x4MxWMCQuA2';//阿里云短信accessKeySecret  
    //private $signName        = '幕小铺';//短信签名 
	
	/**
     * 获取手机号码
	 * @param  int $mobile  		手机号
     * @author 
     * @return mixed
     */
	public function GetMobile($AccessToken){
		AlibabaCloud::accessKeyClient($this -> keyId, $this -> keyScret)
                    ->regionId('cn-hangzhou') //replace regionId as you need（这个地方是发短信的节点，默认即可，或者换成你想要的）
                    ->asGlobalClient();

		try {
			$result = AlibabaCloud::rpc()
								->product('Dypnsapi')
								//->scheme('https') // https | http
								->version('2017-05-25')
								->action('GetMobile')
								->method('POST')
								->host('dypnsapi.aliyuncs.com')
								->options([
												'query' => [
												'RegionId' => "cn-hangzhou",
												'AccessToken' => $AccessToken,
												],
											])
								->request();
			print_r($result->toArray());
		} catch (ClientException $e) {
		echo $e->getErrorMessage() . PHP_EOL;
		} catch (ServerException $e) {
		echo $e->getErrorMessage() . PHP_EOL;
		}
	}
}